<template>
    <Layout>
        <Form ref="form1" :model="form1" :label-width="120">
            <Row class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="检查名称:">
                        <Input type="text" v-model="form1.taskName"/>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="问题状态:">
                        <Select v-model="form1.reportStatus">
                            <Option value=""></Option>
                            <Option value="0">新建</Option>
                            <Option value="1">审核中</Option>
                            <Option value="2">待整改</Option>
                            <Option value="3">整改中</Option>
                            <Option value="4">待验证</Option>
                            <Option value="5">验证中</Option>
                            <Option value="6">已关闭</Option>
                            <Option value="7">验证驳回</Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                    <Button size="large" class="ivu-btn-add" :loading="buttonLoading" icon="md-checkmark"
                            @click="toAssign">批量指派
                    </Button>
                </Col>
            </Row>
        </Form>

        <Table ref='table' :height="tableHeight" size="small" :loading="loading" class="table" no-data-text="没有查询到相关数据!"
               @on-selection-change='getSelectRows' highlight-row stripe border :columns="columns1" width="100%" :data="dataTable">
        </Table>

        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>

        <Modal title="整改安排" :transfer=false v-model="model1" :width=900>
            <Form ref="dataForm" :model="dataForm" :label-width="100" :rules="ruleCustom">
                <Row>
                    <Col span="24" style="font-size:16px;color:#464c5b;font-weight: bold">
                        <Divider orientation="left">问题基本信息</Divider>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="24">
                        <FormItem label="检查名称:" prop="taskName">
                            {{chkProblem.taskName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="detail-background-clor">
                    <Col span="24">
                        <FormItem label="存在单位:" prop="existOrgName">
                            {{chkProblem.existOrgName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" >
                    <Col span="11">
                        <FormItem label="检查人:" prop="reportUserName">
                            {{chkProblem.reportUserName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="检查日期:" prop="reportDate">
                            {{chkProblem.reportDate}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="detail-background-clor">
                    <Col span="11">
                        <FormItem label="问题类型:" prop="problemType">
                            {{chkProblem.problemType=='1'?'基础管理' : '现场管理'}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="问题状态:" prop="reportStatus">
                            {{chkProblem.reportStatusName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" >
                    <Col span="23">
                        <FormItem label="问题图片:" prop="reportFile">
                            <div class="demo-upload-list" v-for="item in uploadList" :key="item.id">
                                <img :src="item.url">
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>
                            </div>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="detail-background-clor">
                    <Col span="23">
                        <FormItem label="问题描述:" prop="reportDesc">
                            {{chkProblem.reportDesc}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="detail-background-clor">
                    <Col span="23">
                        <FormItem label="要求整改时间:">
                            {{chkProblem.rectifyDate}}
                        </FormItem>
                    </Col>
                </Row>
              <!--  <Row type="flex" justify="space-around" class="detail-background-clor">
                    <Col span="23">
                        <FormItem label="备注:" prop="notes">
                            {{chkProblem.notes}}
                        </FormItem>
                    </Col>
                </Row>-->
                <Row>
                    <Col span="24" style="font-size:16px;color:#464c5b;font-weight: bold">
                        <Divider orientation="left">整改安排</Divider>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="整改人:" prop="expectUser">
                            <Select
                                ref="select2"
                                placeholder="请输入关键字查询"
                                v-model="dataForm.expectUser"
                                filterable
                                :remote-method="remoteMethod2"
                                :loading="loading2">
                                <Option v-for="(option, index) in options2" :value="option.userId" :label="option.userName" :key="option.userId">
                                    <span>{{option.userName}}</span>
                                    <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                                </Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="整改期限:" prop="expectDate">
                            <DatePicker type="date" style="width: 100%" format="yyyy-MM-dd"
                                        v-model="dataForm.expectDate"></DatePicker>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="验证人:" prop="verifier">
                             <Select
                                     ref="select3"
                                     placeholder="请输入关键字查询"
                                     v-model="dataForm.verifier"
                                     filterable
                                     :remote-method="remoteMethod3"
                                     :loading="loading3">
                                 <Option v-for="(option, index) in options3" :value="option.userId" :label="option.userName" :key="option.userId">
                                     <span>{{option.userName}}</span>
                                     <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                                 </Option>
                             </Select>
                        </FormItem>
                    </Col>
                    <Col span="11"></Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="整改要求:" prop="expectRect">
                            <Input v-model="dataForm.expectRect" type="textarea" :autosize="{minRows: 3,maxRows: 5}"/>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="填报人:">
                           <!-- <Select disabled
                                    ref="select"
                                    placeholder="请输入关键字查询"
                                    v-model="dataForm.assignUserId"
                                    filterable
                                    :remote-method="remoteMethod1"
                                    :loading="loading1">
                                <Option v-for="(option, index) in options1" :value="option.userId" :label="option.userName" :key="option.userId">
                                    <span>{{option.userName}}</span>
                                    <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                                </Option>
                            </Select>-->
                            {{dataForm.assignUserName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="填报日期:">
                            <!--<DatePicker disabled type="date" style="width: 100%" format="yyyy-MM-dd"-->
                                        <!--v-model="dataForm.assignDate"></DatePicker>-->
                            {{renderViewDate(dataForm.assignDate)}}
                        </FormItem>
                    </Col>
                </Row>
                <!--<Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="上传图片：">
                            <div class="demo-upload-list" v-for="(item, index) in fileList" :key="index">
                                <template>
                                    <img :src="item.imgBase64">
                                    <div class="demo-upload-list-cover">
                                        <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.imgBase64)"></Icon>
                                        <Icon type="ios-trash-outline" @click.native="handleRemove1(item.keyID)"></Icon>
                                    </div>
                                </template>
                            </div>
                            <div class="demo-upload-list" v-for="item in uploadImgs" :key="item.id">
                                <img :src="item.url">
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" v-if="item.url" @click.native="handleView(item.name,item.url)"></Icon>
                                    <Icon type="ios-trash-outline" v-if="!editable"></Icon>
                                    <Icon type="ios-trash-outline" v-else @click.native="handleRemove(item)"></Icon>
                                </div>
                            </div>
                            <Upload
                                    ref="upload"
                                    :show-upload-list="false"
                                    :format="['jpg','jpeg','png']"
                                    :max-size="1024"
                                    :on-format-error="handleFormatError"
                                    :on-exceeded-size="handleMaxSize"
                                    :before-upload="handleBeforeUpload"
                                    multiple
                                    type="drag"
                                    :action="upUrl"
                                    :disabled="!editable"
                                    style="display: inline-block;width:58px;">
                                <div style="width: 58px;height:58px;line-height: 58px;">
                                    <Icon type="ios-camera" size="20"></Icon>
                                </div>
                            </Upload>
                        </FormItem>
                    </Col>
                </Row>-->
            </Form>
            <div slot="footer">
                <Button type="primary" class='ivu-btn-save' :loading="buttonLoading" @click="saveData('2')" style="margin-left: 6px">提交</Button>
                <!--<Button type="primary" class='ivu-btn-save' :loading="buttonLoading" @click="saveData('1')" style="margin-left: 2px">确定</Button>-->
                <Button type="primary" class='ivu-btn-cancel' @click="handleCancel"
                        style="margin-left: 2px">取消
                </Button>
            </div>
        </Modal>
        <Modal title="批量整改安排" :transfer=false v-model="model2" :width=900>
                    <Form ref="dataForm" :model="dataForm" :label-width="100" :rules="ruleCustom">

                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label="整改人:" prop="expectUser">
                                    <Select
                                        ref="select2"
                                        placeholder="请输入关键字查询"
                                        v-model="dataForm.expectUser"
                                        filterable
                                        :remote-method="remoteMethod2"
                                        :loading="loading2">
                                        <Option v-for="(option, index) in options2" :value="option.userId" :label="option.userName" :key="option.userId">
                                            <span>{{option.userName}}</span>
                                            <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label="整改期限:" prop="expectDate">
                                    <DatePicker type="date" style="width: 100%" format="yyyy-MM-dd"
                                                v-model="dataForm.expectDate"></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label="验证人:" prop="verifier">
                                     <Select
                                             ref="select3"
                                             placeholder="请输入关键字查询"
                                             v-model="dataForm.verifier"
                                             filterable
                                             :remote-method="remoteMethod3"
                                             :loading="loading3">
                                         <Option v-for="(option, index) in options3" :value="option.userId" :label="option.userName" :key="option.userId">
                                             <span>{{option.userName}}</span>
                                             <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                                         </Option>
                                     </Select>
                                </FormItem>
                            </Col>
                            <Col span="11"></Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label="整改要求:" prop="expectRect">
                                    <Input v-model="dataForm.expectRect" type="textarea" :autosize="{minRows: 3,maxRows: 5}"/>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label="填报人:">

                                    {{dataForm.assignUserName}}
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label="填报日期:">
                                    {{renderViewDate(dataForm.assignDate)}}
                                </FormItem>
                            </Col>
                        </Row>

                    </Form>
                    <div slot="footer">
                        <Button type="primary" class='ivu-btn-save' :loading="buttonLoading" @click="submitAssign()" style="margin-left: 6px">提交</Button>
                        <Button type="primary" class='ivu-btn-cancel' @click="handleCancel2"
                                style="margin-left: 2px">取消
                        </Button>
                    </div>
                </Modal>
        <Modal title="整改安排查看" :transfer=false class="modal-view-detail" v-model="viewModal" :width=900>
            <Form ref="viewForm" :label-width="100">
                <Row>
                    <Col span="24" style="font-size:16px;color:#464c5b;font-weight: bold">
                        <Divider orientation="left">问题基本信息</Divider>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="24">
                        <FormItem label="检查名称:" prop="taskName">
                            {{chkProblem.taskName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="24">
                        <FormItem label="存在单位:" prop="existOrgName">
                            {{chkProblem.existOrgName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="检查人:" prop="reportUserName">
                            {{chkProblem.reportUserName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="检查日期:" prop="reportDate">
                            {{chkProblem.reportDate}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="问题类型:" prop="problemType">
                            {{chkProblem.problemType=='1'?'基础管理' : '现场管理'}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="问题状态:" prop="reportStatus">
                            {{chkProblem.reportStatusName}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="问题图片:" prop="reportFile">
                            <div class="demo-upload-list" v-for="item in uploadList" :key="item.id">
                                <img :src="item.url">
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>
                            </div>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="问题描述:" prop="reportDesc">
                            {{chkProblem.reportDesc}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="detail-background-clor">
                    <Col span="23">
                        <FormItem label="要求整改时间:">
                            {{chkProblem.rectifyDate}}
                        </FormItem>
                    </Col>
                </Row>
               <!-- <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="备注:" prop="notes">
                            {{chkProblem.notes}}
                        </FormItem>
                    </Col>
                </Row>-->
                <Row>
                    <Col span="24" style="font-size:16px;color:#464c5b;font-weight: bold">
                        <Divider orientation="left">整改安排</Divider>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="整改人:" prop="expectUser">
                            {{viewForm.expectUserName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="整改期限:" prop="expectDate">
                            {{viewForm.expectDate}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="验证人:" >
                            {{viewForm.verifierName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="整改要求:" prop="expectRect">
                            {{viewForm.expectRect}}
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="11">
                        <FormItem label="填报人:" prop="assignUserId">
                            {{viewForm.assignUserName}}
                        </FormItem>
                    </Col>
                    <Col span="11">
                        <FormItem label="填报日期:" prop="assignDate">
                            {{viewForm.assignDate}}
                        </FormItem>
                    </Col>
                </Row>
               <!-- <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label="审核图片:" prop="reportFile">
                            <div class="demo-upload-list" v-for="item in uploadImgs" :key="item.id">
                                <img :src="item.url">
                                <div class="demo-upload-list-cover">
                                    <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                                </div>
                            </div>
                        </FormItem>
                    </Col>
                </Row>-->
                <!-- <Row type="flex" justify="space-around" class="code-row-bg">
                     <Col span="23">
                         <FormItem>
                             <Button class='ivu-btn-save' @click="viewModal=false">关闭</Button>
                         </FormItem>
                     </Col>
                 </Row>-->
            </Form>
            <div slot="footer">
                <Button class='ivu-btn-save' @click="viewModal=false">关闭</Button>
            </div>
        </Modal>

        <Modal v-model="visible">
            <img :src="viewUrl" style="width: 100%">
            <div slot="footer">
                <Button type="primary" class='ivu-btn-save'  @click="visible=false">关闭</Button>
            </div>
        </Modal>
    </layout>
</template>

<script>
    import {Api} from '../../../../api/index.js'
    import cascaderDom from '../../../../components/cascader-dom'
    import {sessionStorage} from '../../../../common/cacheUtils.js';
    import pageCommonFunction from '../../../../components/pageCommonFunction.js'
    export default {
        components: {
            cascaderDom
        },
        data() {
/*            const expectUserVal = (rule, value, callback) => {
                if (this.dataForm.expectUser !== null && this.dataForm.expectUser !== undefined) {
                    callback();
                } else {
                    callback(new Error(' '));
                }
            };
            const assignUserIdVal = (rule, value, callback) => {
                if (this.dataForm.assignUserId !== null && this.dataForm.assignUserId !== undefined) {
                    callback();
                } else {
                    callback(new Error(' '));
                }
            };  */

            return {
                loading1:false,
                loading2:false,
                loading3:false,
                options1:[],
                options2:[],
                options3:[],
                form1: {},
                dataForm: {},
                selectRows: [],
                chkProblem: {},
                //分页参数
                pageSizeArray: [10, 20, 50],
                pagedata: {
                    total: 0,
                    pageSize: 10,
                    currentPage: 1,
                },
                columns1: [
                    {
                        title: "序号",
                        width: 80,
                        align: "center",
                        fixed: 'left',
                        type: 'selection',
                        render: (h, params) => {
                            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
                        }
                    },
                    {
                        minWidth: 220,
                        title: '检查名称',
                        key: 'taskName',
                        align: 'center'
                    },
                    {
                        minWidth: 100,
                        title: '检查人',
                        key: 'reportUserName',
                        align: 'center'
                    },
                    {
                        minWidth: 130,
                        title: '检查日期',
                        key: 'reportDate',
                        align: 'center'
                    },
                    {
                        minWidth: 180,
                        title: '存在单位',
                        key: 'existOrgName',
                        align: 'center'
                    },
                    {
                        minWidth: 100,
                        title: '问题类型',
                        align: 'center',
                        key: 'problemType',
                        render: (h, params) => {
                            if (params.row.problemType == '1') {
                                return h('span', {}, '基础管理')
                            } else if (params.row.problemType == '2') {
                                return h('span', {}, '现场管理')
                            }
                        }
                    },
                    {
                        minWidth: 180,
                        title: '问题描述',
                        key: 'reportDesc',
                        align: 'center',
                        tooltip:true
                       /* render: (h, params) => {
                            return h('div', [
                                h('span', (params.row.reportDesc && params.row.reportDesc.length) < 10 ?
                                    params.row.reportDesc : params.row.reportDesc.substr(0, 9) + '...')
                            ]);
                        }*/
                    },
                    /*{
                        minWidth: 80,
                        title: '照片',
                        key: 'reportFile',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Icon', {
                                    props: {
                                        type: 'md-eye',
                                        size: '20'
                                    },
                                    style: {
                                        marginRight: "0px"
                                    },
                                    on: {
                                        click: () => {
                                            this.viewData(params);
                                        }
                                    }
                                }),
                            ]);
                        }
                    },*/
                    {
                        minWidth: 120,
                        title: '问题状态',
                        align: 'center',
                        key: 'reportStatus',
                        render: (h, params) => {
                            if (params.row.reportStatus == '0') {
                                return h('span', {}, '新建')
                            } else if (params.row.reportStatus == '1') {
                                return h('span', {}, '审核中')
                            } else if (params.row.reportStatus == '2') {
                                return h('span', {}, '待整改')
                            } else if (params.row.reportStatus == '3') {
                                return h('span', {}, '整改中')
                            } else if (params.row.reportStatus == '4') {
                                return h('span', {}, '待验证')
                            } else if (params.row.reportStatus == '5') {
                                return h('span', {}, '验证中')
                            } else if (params.row.reportStatus == '6') {
                                return h('span', {}, '已关闭')
                            } else if (params.row.reportStatus == '7') {
                                return h('span', {}, '验证驳回')
                            }
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        minWidth: 120,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.viewData(params);
                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: (params.row.reportStatus == '0' || params.row.reportStatus == '1') ? '' : '#d0d0d0',
                                        pointerEvents: (params.row.reportStatus == '0' || params.row.reportStatus == '1') ? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.toEdit(params);
                                        }
                                    }
                                }, '指派'),
                            ]);

                        }
                    }
                ],
                ruleCustom: {
                    expectUser: [{required: true,  message: '请填写整改人', trigger: 'change'}],
                    assignUserId: [{required: true, message: '请填写验证人',  trigger: 'change'}],
                    expectDate: [{required: true, message: '  ', trigger: 'blur', type: 'date'}],
                    assignDate: [{required: true, message: '  ', trigger: 'blur', type: 'date'}],
                    verifier: [{required: true,  message: '  ', trigger: 'change'}],
                },
                dataTable: [],
                model1: false,
                model2: false,
                tableHeight: '', loading: false,
                buttonLoading: false, viewModal: false,
                viewForm: {},
                setCurrentExpectUserName: {},
                setCurrentAssignUserName: {},

                uploadList: [],
                uploadImgs: [],
                fileList:[],
                visible: false,
                viewUrl: null,
                upUrl: Api.uploadPTWFiles,
                editable: false,
            }
        },
        mounted: function () {
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.query();
        },
        methods: {
            ...pageCommonFunction,
            remoteMethod1(query){
                if(this.dataForm.assignUserId == query){
                        return ;
                }
                if (query !== '') {
                    clearTimeout(this.remoteMethod1.timer);
                    this.remoteMethod1.timer = setTimeout(()=>{
                        this.loading1 = true;
                        let data = {
                            userName: query,
                            orgId: sessionStorage('userId').getObject('userId').orgInfo.parentId
                        };
                        this.$http.get(Api.queryUserByUserName , {params: data}).then((res) => {
                            this.loading1 = false;
                            this.options1 = res.data.data;
                        }).catch(e => {
                            this.loading1 = false;
                        })
                    },200);
                } else {
                    this.options1 = [];
                }
            },
            remoteMethod2(query){
                if(this.dataForm.expectUser == query){
                    return ;
                }
                if (query !== '') {
                    clearTimeout(this.remoteMethod2.timer);
                    this.remoteMethod2.timer = setTimeout(()=>{
                        this.loading2 = true;
                        let data = {
                            userName: query,
                            orgId: sessionStorage('userId').getObject('userId').orgInfo.parentId
                        };
                        this.$http.get(Api.queryUserByUserName , {params: data}).then((res) => {
                            this.loading2 = false;
                            this.options2 = res.data.data;
                        }).catch(e => {
                            this.loading2 = false;
                        })
                    },200);
                } else {
                    this.options2 = [];
                }
            },
            remoteMethod3(query){
                if(this.dataForm.verifier == query){
                    return ;
                }
                if (query !== '') {
                    clearTimeout(this.remoteMethod3.timer);
                    this.remoteMethod3.timer = setTimeout(()=>{
                        this.loading3 = true;
                        let data = {
                            userName: query,
                            orgId: sessionStorage('userId').getObject('userId').orgInfo.parentId
                        };
                        this.$http.get(Api.queryUserByUserName , {params: data}).then((res) => {
                            this.loading3 = false;
                            this.options3 = res.data.data;
                        }).catch(e => {
                            this.loading3 = false;
                        })
                    },200);
                } else {
                    this.options3 = [];
                }
            },
            handleRemove1(keyID){
                this.fileList = this.fileList.filter(item => {
                    return item.keyID != keyID
                })
            },
            handleRemove(file) {
                //删除操作
                let _this = this;
                let config = {
                    title: '系统提示',
                    content: '确认删除图片吗?',
                    okText: '确定',
                    cancelText: '取消',
                    onOk: function () {

                        _this.$Spin.show({
                            render: (h) => {
                                return h('div', [
                                    h('Icon', {
                                        'class': 'demo-spin-icon-load',
                                        props: {
                                            type: 'ios-loading',
                                            size: 18
                                        }
                                    }),
                                    h('div', 'Loading')
                                ])
                            }
                        });
                        _this.uploadImgs.splice(_this.uploadImgs.indexOf(file), 1);

                        _this.$http.delete(Api.downloadPTWSchemeFile + '/' + file.id).then((res) => {
                            _this.$Message.success('删除成功');
                            /*  _this.uploadImgs = [];
                              _this.$http.get(_this.upUrl, {params: {}}).then((res) => {
                                  if(res.data.data!=null){
                                      res.data.data.map((item)=>{
                                          _this.uploadImgs.push({ name : item.fileName, id : item.id , url : Api.downloadPTWSchemeFile + '/' + item.id});
                                      });
                                  }
                              }).catch(e => {
                                  console.log(e)
                                  this.$Message.error("数据获取失败")
                              })*/

                            _this.$Spin.hide();
                        }).catch(e => {
                            _this.$Spin.hide();
                            _this.$Message.error('删除失败' + e);
                        })
                    },
                    onCancel: function () {
                    }
                }
                this.$Modal.confirm(config);
            },
            handleFormatError(file) {
                this.$Message.error('格式不正确, 请上传 jpg 或 png');
            },
            handleMaxSize(file) {
                this.$Message.error('图片不能大于1M.');
            },
            handleBeforeUpload(file) {
                if (file.size > 1024 * 1024) {
                    this.$Message.error('图片不能大于1M.');
                    return false;
                }
                var index = file.name.lastIndexOf(".");
                var suffix = file.name.substr(index + 1);

                if (suffix != 'jpg' && suffix != 'jpeg' && suffix != 'png') {
                    this.$Message.error("请上传jpg,jpeg,png格式的图片");
                    return false;
                }

                const check = this.uploadImgs.length < 3;
                if (!check) {
                    this.$Message.error('最多上传3张图片');
                    return false;
                } else {
                    // this.uploadImgs.push(file);
                    let self = this;
                    let keyID = Math.random().toString().substr(2);
                    file['keyID'] = keyID;
                    let reader = new FileReader();
                    reader.readAsDataURL(file);
                    reader.onload = function(ev) { //文件读取成功完成时触发
                        file['imgBase64'] = ev.target.result; //获得文件读取成功后的DataURL,也就是base64编码
                        self.fileList.push(file);
                    }

                }
                return false;
            },

            handleView(name, url) {
                this.viewUrl = url;
                this.imgName = name;
                this.visible = true;
            },

            viewPicture(row) {
                //根据reportFile查询附件
                this.uploadList = [];
                this.$http.get(Api.uploadPTWFiles + '/' + row.reportFile + '/files', {params: {}}).then((res) => {
                    if (res.data.data != null) {
                        res.data.data.map((item) => {
                            this.uploadList.push({
                                name: item.fileName,
                                id: item.id,
                                url: Api.downloadPTWSchemeFile + '/' + item.id
                            });
                        });
                    }
                    //this.downloadUrl = this.downloadUrl + '/' + res.data.id;
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })
            },

            viewAuditPicture(row) {
                //根据reportFile查询附件
                this.uploadImgs = [];
                this.$http.get(Api.uploadPTWFiles + '/' + row.assignId + '/files', {params: {}}).then((res) => {
                    if (res.data.data != null) {
                        res.data.data.map((item) => {
                            this.uploadImgs.push({
                                name: item.fileName,
                                id: item.id,
                                url: Api.downloadPTWSchemeFile + '/' + item.id
                            });
                        });
                    }
                    //this.downloadUrl = this.downloadUrl + '/' + res.data.id;
                }).catch(e => {
                    console.log(e)
                    this.$Message.error("数据获取失败")
                })
            },
            submitAssign(){
                this.$refs.dataForm.validate((valid) => {
                    if (valid) {
                        let _this = this;
                        let config = {
                            title: '系统提示',
                            content: '提交后不可修改，是否确认提交?',
                            okText: '确定',
                            cancelText: '取消',
                            onOk: function () {
                                _this.buttonLoading = true
                                _this.dataForm.expectDate = _this.formatDate(new Date(_this.dataForm.expectDate), 'yyyy-MM-dd');
                                _this.dataForm.assignDate = _this.formatDate(new Date(_this.dataForm.assignDate), 'yyyy-MM-dd');
                                _this.dataForm.reportStatus = '2';
                                let problemId = '';
                                for(let i=0;i<_this.selectRows.length;i++){
                                    problemId += _this.selectRows[i].problemId;
                                    if(i!=_this.selectRows.length-1) problemId += ";";
                                }
                                _this.dataForm.problemId = problemId;

                                _this.options1.forEach(item=>{
                                    if(item.userId == _this.dataForm.assignUserId)
                                        _this.dataForm.assignUserName = item.userName;
                                })
                                _this.options2.forEach(item=>{
                                    if(item.userId == _this.dataForm.expectUser)
                                        _this.dataForm.expectUserName = item.userName;
                                })
                                _this.options3.forEach(item=>{
                                    if(item.userId == _this.dataForm.verifier)
                                        _this.dataForm.expectUserName = item.userName;
                                })
                                _this.$http.post(Api.submitChkAssign, _this.dataForm).then((res) => {
                                    _this.$Message.success("提交成功");
                                    _this.model2 = false;
                                    _this.query();
                                    _this.buttonLoading = false

                                }).catch(e => {
                                    _this.model2 = false;
                                    _this.query();
                                    _this.buttonLoading = false
                                    _this.$Message.error("数据保存失败")
                                })
                            },
                            onCancel: function () {
                            }
                        }
                        this.$Modal.confirm(config);

                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })

            },
            handleCancel2() {
                this.dataForm = {};
                this.model2 = false;
            },
            handleCancel() {
                this.model1 = false;
            },
            getSelectRows(rows) {
                this.selectRows = rows;
            },
            addInfo() {
                this.dataForm = {};
                this.setCurrentExpectUserName = {};
                this.setCurrentAssignUserName = {
                    label: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"],
                    value: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
                };
                this.model1 = true;
            },

            setExpectUserName(data) {
                this.dataForm.expectUserName = data;
            },
            setExpectUserId(data) {
                this.dataForm.expectUser = data[data.length - 1];
            },

            setAssignUserName(data) {
                this.dataForm.assignUserName = data;
            },
            setAssignUserId(data) {
                this.dataForm.assignUserId = data[data.length - 1];
            },

            pageChange(pageNum) {
                this.pagedata.currentPage = pageNum;
                this.query();
            },
            pageSizeChange(pageSize) {
                this.pagedata.pageSize = pageSize;
                this.query();
            },

            toEdit(params) {
                this.fileList=[]
                this.dataForm = {};
                this.editable = true;
                let url = Api.toChkProblemAssign + '/' + params.row.problemId;
                this.$http.get(url, {}).then((res) => {
                    this.model1 = true;
                    this.chkProblem = res.data.chkProblem;
                    if (res.data.chkAssign != null) {
                        this.dataForm = res.data.chkAssign;
                        this.options2=[{}];
                        this.$set(this.options2[0],'userId',res.data.chkAssign.expectUser);
                        this.$set(this.options2[0],'userName',res.data.chkAssign.expectUserName);
                        this.$set(this.options2[0],'orgInfo',{orgName:'xx'});

                        this.options3=[{}];
                        this.$set(this.options3[0],'userId',res.data.chkAssign.verifier);
                        this.$set(this.options3[0],'userName',res.data.chkAssign.verifierName);
                        this.$set(this.options3[0],'orgInfo',{orgName:'xx'});
                        this.viewAuditPicture(res.data.chkAssign);
                    } else {
                        this.dataForm = {};
                        this.uploadImgs = [];
                    }
                    if (res.data.chkAssign != null &&res.data.chkAssign.assignUserId != undefined && res.data.chkAssign.assignUserId != null && res.data.chkAssign.assignUserId != '') {
                        this.options1=[{}];
                        this.$set(this.options1[0],'userId',res.data.chkAssign.assignUserId);
                        this.$set(this.options1[0],'userName',res.data.chkAssign.assignUserName);
                        this.$set(this.options1[0],'orgInfo',{orgName:'xx'});
                    } else {
                        var label= JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"]
                        var value= JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
                        this.options1=[{}];
                        this.$set(this.options1[0],'userId',value);
                        this.$set(this.options1[0],'userName',label);
                        this.$set(this.options1[0],'orgInfo',{orgName:'xx'});
                        this.dataForm.assignUserId = value;
                        this.dataForm.assignUserName = label;
                        this.dataForm.assignDate=new Date()
                    }

                    if (this.chkProblem.reportStatus == '0') {
                        this.chkProblem.reportStatusName = '新建';
                    } else if (this.chkProblem.reportStatus == '1') {
                        this.chkProblem.reportStatusName = '审核中';
                    } else if (this.chkProblem.reportStatus == '2') {
                        this.chkProblem.reportStatusName = '待整改';
                    } else if (this.chkProblem.reportStatus == '3') {
                        this.chkProblem.reportStatusName = '整改中';
                    } else if (this.chkProblem.reportStatus == '4') {
                        this.chkProblem.reportStatusName = '待验证';
                    } else if (this.chkProblem.reportStatus == '5') {
                        this.chkProblem.reportStatusName = '验证中';
                    } else if (this.chkProblem.reportStatus == '6') {
                        this.chkProblem.reportStatusName = '已关闭';
                    } else if (this.chkProblem.reportStatus == '7') {
                        this.chkProblem.reportStatusName = '验证驳回';
                    }
                   /* setTimeout(() => {
                        this.$refs.childUser2.setCurrentUser();
                    }, 300);*/

                    this.viewPicture(this.chkProblem);
                }).catch(e => {
                    this.$Message.error('请求失败' + e);
                })
            },
            toAssign() {
                let selectRows = this.selectRows;
                if (selectRows.length == 0) {
                    this.$Message.info('请至少选择一条数据！');
                    return;
                }
                this.dataForm = {};
                var label= JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"]
                var value= JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
                this.dataForm.assignUserId = value;
                this.dataForm.assignUserName = label;
                this.dataForm.assignDate=new Date();
                this.model2 = true;
            },
            viewData(params) {
                this.editable = false;
                let url = Api.toChkProblemAssign + '/' + params.row.problemId;
                this.$http.get(url, {}).then((res) => {
                    this.viewModal = true;
                    this.chkProblem = res.data.chkProblem;
                    if (res.data.chkAssign != null) {
                        this.viewForm = res.data.chkAssign;
                        this.viewAuditPicture(res.data.chkAssign);
                    } else {
                        this.viewForm = {};
                        this.uploadImgs = [];
                    }
//                    this.setCurrentExpectUserName = {value: res.data.expectUser, label: res.data.expectUserName};
//                    this.setCurrentAssignUserName = {value: res.data.assignUserId, label: res.data.assignUserName};

                    if (this.chkProblem.reportStatus == '0') {
                        this.chkProblem.reportStatusName = '新建';
                    } else if (this.chkProblem.reportStatus == '1') {
                        this.chkProblem.reportStatusName = '审核中';
                    } else if (this.chkProblem.reportStatus == '2') {
                        this.chkProblem.reportStatusName = '待整改';
                    } else if (this.chkProblem.reportStatus == '3') {
                        this.chkProblem.reportStatusName = '整改中';
                    } else if (this.chkProblem.reportStatus == '4') {
                        this.chkProblem.reportStatusName = '待验证';
                    } else if (this.chkProblem.reportStatus == '5') {
                        this.chkProblem.reportStatusName = '验证中';
                    } else if (this.chkProblem.reportStatus == '6') {
                        this.chkProblem.reportStatusName = '已关闭';
                    } else if (this.chkProblem.reportStatus == '7') {
                        this.chkProblem.reportStatusName = '验证驳回';
                    }
                   /* setTimeout(() => {
                        this.$refs.childUser2.setCurrentUser();
                    }, 300);*/
                    this.viewPicture(this.chkProblem);
                }).catch(e => {
                    this.$Message.error('请求失败' + e);
                })
            },
            saveData(tag) {
                this.$refs.dataForm.validate((valid) => {
                    if (valid) {
                        let _this = this;
                        let config = {
                            title: '系统提示',
                            content: '提交后不可修改，是否确认提交?',
                            okText: '确定',
                            cancelText: '取消',
                            onOk: function () {
                                _this.buttonLoading = true
                                _this.dataForm.expectDate = _this.formatDate(new Date(_this.dataForm.expectDate), 'yyyy-MM-dd');
                                _this.dataForm.assignDate = _this.formatDate(new Date(_this.dataForm.assignDate), 'yyyy-MM-dd');
                                if (tag == '1') {
                                    //保存
                                    _this.dataForm.reportStatus = '1';
                                } else if (tag == '2') {
                                    //提交
                                    _this.dataForm.reportStatus = '2';
                                }
                                _this.dataForm.problemId = _this.chkProblem.problemId;
                                _this.options1.forEach(item=>{
                                    if(item.userId == _this.dataForm.assignUserId)
                                        _this.dataForm.assignUserName = item.userName;
                                })
                                _this.options2.forEach(item=>{
                                    if(item.userId == _this.dataForm.expectUser)
                                        _this.dataForm.expectUserName = item.userName;
                                })
                                _this.options3.forEach(item=>{
                                    if(item.userId == _this.dataForm.verifier)
                                        _this.dataForm.expectUserName = item.userName;
                                })
                                _this.$http.post(Api.saveOrSubmitChkAssign, _this.dataForm).then((res) => {
                                    // if (this.uploadImgs.length > 0 || this.fileList.length>0) {
                                    /* let formData = new FormData();
                                     for (let i = 0; i < this.uploadImgs.length; i++) {
                                         formData.append("files", this.uploadImgs[i]);
                                     }
                                     for (let i = 0; i < this.fileList.length; i++) {
                                         formData.append("files", this.fileList[i]);
                                     }
                                     this.$http.post(Api.uploadPTWFiles + '/' + res.data.assignId + '/files/picture', formData).then((res) => {
                                         if (res.data.result == "success") {
                                             this.$Message.success("保存成功");
                                             //this.uploadList.push(file);
                                             this.model1 = false;
                                             this.query();
                                         } else {
                                             this.$Message.error("附件上传失败");
                                             this.model1 = false;
                                             this.query();
                                         }
                                         this.buttonLoading = false
                                     }).catch(e => {
                                         console.log(e);
                                         this.buttonLoading = false
                                         this.$Message.error("附件上传失败");
                                     })*/
                                    // } else {
                                    _this.$Message.success("提交成功");
                                    _this.model1 = false;
                                    _this.query();
                                    _this.buttonLoading = false
                                    // }
                                }).catch(e => {
                                    console.log(e)
                                    _this.model1 = false;
                                    _this.query();
                                    _this.buttonLoading = false
                                    _this.$Message.error("数据保存失败")
                                })
                            },
                            onCancel: function () {
                            }
                        }
                        this.$Modal.confirm(config);

                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })
            },
            query() {
                this.loading = true;
                let data = {
                    currentPage: this.pagedata.currentPage,
                    size: this.pagedata.pageSize,
                    userId: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"],
                    checkCategory: this.$route.query.id
                }

                data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));

                let url = Api.getChkProblemList;
                this.$http.get(url, {params: data}).then((res) => {
                    for (var i = 0; i < res.data.data.length; i++) {
                          if (res.data.data[i].reportStatus != '0' && res.data.data[i].reportStatus != '1') {
                              res.data.data[i]._disabled = true;
                          }
                      };
                      this.dataTable = res.data.data;

                    this.pagedata.total = res.data.totalSize;
                    this.loading = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            reset() {
                this.form1 = {};
                this.query();
            },

            deleteData(params) {
                let _this = this;
                let config = {
                    title: '系统提示',
                    content: '确认删除选中数据吗?',
                    okText: '确定',
                    cancelText: '取消',
                    onOk: function () {
                        _this.$Spin.show({
                            render: (h) => {
                                return h('div', [
                                    h('Icon', {
                                        'class': 'demo-spin-icon-load',
                                        props: {
                                            type: 'ios-loading',
                                            size: 18
                                        }
                                    }),
                                    h('div', 'Loading')
                                ])
                            }
                        });
                        let url = Api.deleteSecurityCheckTaskDetailById + '/' + params.row.mainTaskId;
                        this.$http.get(url, {params: {}}).then((res) => {
                            _this.$Message.success('删除成功');
                            _this.query();
                            _this.$Spin.hide();
                        }).catch(e => {
                            _this.$Spin.hide();
                            _this.$Message.error('删除失败' + e);
                        })
                    },
                    onCancel: function () {
                    }
                }
                this.$Modal.confirm(config);
            },
            formatDate(date, fmt) {
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                let o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (let k in o) {
                    if (new RegExp(`(${k})`).test(fmt)) {
                        let str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
                    }
                }
                return fmt;
            },
            padLeftZero(str) {
                return ('00' + str).substr(str.length);
            },
        },
    }
</script>
<style lang='css'>
    @import '../../../../index.css';

    .demo-upload-list {
        display: inline-block;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
        margin-right: 4px;
    }

    .demo-upload-list img {
        width: 100%;
        height: 100%;
    }

    .demo-upload-list-cover {
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .6);
    }

    .demo-upload-list:hover .demo-upload-list-cover {
        display: block;
    }

    .demo-upload-list-cover i {
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }
</style>
